package tech.jabari.user.controller;

import tech.jabari.user.service.UserService;
import tech.jabari.user.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delUser.action")
public class DelUserServlet extends HttpServlet {
    private UserService userService = new UserServiceImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //todo: 调用Service来删除用户
        String id = request.getParameter("id");
        int r = userService.delUser(id);
        if (r > 0) {
            response.getWriter().write("OK");
        } else {
            response.getWriter().write("NO");
        }

    }
}
